<div class="row"><h3 class="page-header">采购管理</h3></div>
<div class="row">
    <div class="panel panel-default">
        <div class="panel-body">
          <a  data-id='{$list.id}' href='{:U("Cggl/cgsq?id=".$list["id"])}'><button class="btn btn-primary" type="submit">填写申请</button></a>
            <form action='{:U("Cggl/cggl")}' class="form-inline text-right fr m-b-5">
                系部名称：<input type="text" name='xibu' value='{$Think.get.xibu}' class="form-control mr20 w150" >
            </select>
                <button class="btn btn-primary" type="submit">搜索</button>
            </form>
            <div class="table-responsive">
                <table class="table table-striped table-bordered table-hover">
                    <thead>
                    <tr>
                        <th width="60">序号</th>
                        <th>系部</th>
                        <th>填报人</th>
                        <th>填报时间</th>
                        <th>类别</th>
                        <th>总金额</th>
                        <th>审核环节</th>
                        <th>审核情况</th>
                        <th  width="200">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                     <empty name="list">
                         <tr><td colspan="9" align="center">暂无信息</td></tr>
                     </empty>
                    <volist name="list" id="list">
                        <tr>
                            <td>{$i}</td>
                            <td>{$list.xibu}</td>
                            <td>{$list.user_name}</td>
                            <td>{$list.tianbaoshijian|date="Y-m-d",###}</td>
                            <td>{$list.category}</td>
                            <td>{$list.jine}</td>
                            <td>{$_act_show[$list['act_id']]}</td>
                            <td>{$_act_status[$list['status']]}</td>
                            <td>
                              <a class="btn-sm btn btn-default" data-id='{$_list.id}' href='{:U("Cggl/select?id=".$list["id"])}'>浏览</a>
                              <if condition="$list['act_id'] eq 0">
                                <a class="btn-sm btn btn-default editText" data-id='{$list.id}'>修改</a>
                                <button data-url='{:U("Cggl/del?id=".$list["id"])}' class="btn btn-default btn-sm delBtn" type="button">删除</button>
                                </if>
                            </td>
                        </tr>
                    </volist>
                    </tbody>
                </table>
            </div>
            {$page}
        </div>
  </div>
</div>
<div id="myModal" class="modal fade in" style="display: none;">
    <div class="modal-dialog" style="width:880px;">
        <div class="modal-content">
            <form action="{:U('Cggl/edit')}" id="myform" class="form-horizontal" data-callback="_form_defult_callback">
                <div class="modal-header">
                    <button data-dismiss="modal" class="close" type="button">×</button>
                    <h4 class="modal-title">采购管理</h4>
                </div>
                 <div class="modal-body">
                <div class="group">
                <div class="form-group">
                    <label class="col-sm-4 control-label">系部：</label>
                    <div class="col-sm-6 input-group" name="xibu" style="margin-top:7px;"></div>
                </div>
                <div class="form-group">
                    <label class="col-sm-4 control-label">类别：<span class="c-red">*</span></label>
                    <div class="col-sm-6 input-group">
                        <select class="form-control required" name="category">
                          <volist name='list_cke' id='list_ck'>
                                <option value="{$list_ck.name}"> 
                                         {$list_ck.name}
                                </option>
                             </volist>
                        </select>           
                    </div>
                </div>
              <div class="form-group">
                  <label class="col-sm-4 control-label">填报人：</label>
                  <div class="col-sm-6 input-group" name="user_name" style="margin-top:7px;"></div>
              </div>
              
               <div class="form-group">
                  <label class="col-sm-4 control-label">填报日期：</label>
                  <div class="col-sm-6 input-group" name="tianbaoshijian" style="margin-top:7px;"></div>
              </div>
              </div>
            <table class="table table-striped table-bordered table-hover" style="margin-bottom:0px;">
                   <thead>
                    <tr>
                        <th>品名</th>
                        <th>规格型号</th>
                        <th>单位</th>
                        <th>单价</th>
                        <th>数量</th>
                        <th>金额</th>
                        <th colspan="3" style="text-align:center;">备注</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <td><input type="text" name="name" class="form-control"/></td>
                        <td><input type="text" name="guige" class="form-control"/></td>
                        <td><input type="text" name="danwei" class="form-control" /></td>
                        <td><input type="text" onkeyup="jisuan();" id="text1" name="danjia" class="form-control" style="text-align:right;" /></td>
                        <td><input type="text" onkeyup="jisuan();"  id="text2" name="shuliang" class="form-control" style="text-align:right;" /></td>
                        <td><input type="text" onkeyup="jisuan();" id="text3" name="jine" class="form-control" style="text-align:right;" /></td>
                        <td><input type="text" class="form-control" name="beizhu" /></td>
                    </tr>
                    <tr>
                  <div class="uploadify-div"></div>
                    <button class="upload" data-type="file" name="file" type="button" id="upload">上传附件</button></tr>
                    </tbody>
                    </table>
                </div>
                <div class="modal-footer">
                    <div style="width: 200px;">
                        <select class="form-control" name="act_type">
                            <option value="save">仅保存</option>
                            <option value="saveSubmit">保存并提交审核</option>
                        </select>
                    </div>
                 <button class="btn btn-primary" type="submit">保存</button>
                 <button data-dismiss="modal" class=" btn btn-default" type="button">关闭</button>
                </div>  
                <input type='hidden' name='id' value='{$info.id}'>
                
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
var jisuan=function(){
           $("#text1").val($("#text1").val().replace(/[^\d^\.]+/g, ''));
            $("#text2").val($("#text2").val().replace(/^(0+)|[^\d]+/g, ''));           
            $("#text3").val(parseFloat($("#text1").val())*parseFloat($("#text2").val()));
            $("#text3").val($("#text3").val().replace(/[^\d^\.]+/g, ''));
            }
$(function(){
    $('.editText').click(function(){
        $('#myModal').modal('show');
        var id = $(this).data('id'); 
        waiting();
        $.get('{:U("Cggl/edit")}', {id: id}, function(data){
            complete();
            if(data.status == 1){
                var _get_info = data.info;
                $('#myform input[name="id"]').val(_get_info.id);
                $('#myform div[name="xibu"]').html(_get_info.xibu);
                $('#myform select[name="category"]').val(_get_info.category);
                $('#myform div[name="user_name"]').html(_get_info.user_name);
                $('#myform div[name="tianbaoshijian"]').html(_get_info.tianbaoshijian);
                $('#myform input[name="name"]').val(_get_info.name);
                $('#myform input[name="guige"]').val(_get_info.guige);
                $('#myform input[name="danwei"]').val(_get_info.danwei);
                $('#myform input[name="danjia"]').val(_get_info.danjia);
                $('#myform input[name="shuliang"]').val(_get_info.shuliang);
                $('#myform input[name="jine"]').val(_get_info.jine);
                $('#myform input[name="beizhu"]').val(_get_info.beizhu);
                 var div = $('.uploadify-div');
                if(_get_info.file.length > 0){
                    //有图片
                    var html = '<li>';
                    html += "<a href='"+_get_info.file+"'>附件查看</a>";
                    html += "<input type='hidden' name='file' value='"+_get_info.file+"' /><span style='color:blue;cursor:pointer;' class='uploadifyDel'>删除</span></li>";
                    div.html(html);
                }else{
                    div.html("");
                }

                $('#myform').attr('action', '{:U("Cggl/edit")}');           
                $('#myModal').modal('show');
            }else{
                showInfo(data.info);
                setTimeout('_form_defult_callback()', 1600);
            }
        });
    });
});
</script>